# encoding=utf-8
import time

from MPU6050Api import MPU6050, MPU6050Api
from MPU6050CalApi import MPU6050CalApi

if __name__ == '__main__':
    mpu_tools = MPU6050(i2c_bus=8, i2c_address=0x68)
    mpu_tools.open()
    mpu_api = MPU6050Api(mpu_tools)
    mpu_api.init_6050()
    mpu_cal_api = MPU6050CalApi(mpu_api)

    while True:
        acc_angle, angle = mpu_cal_api.calculate(1)
        x, y, z = acc_angle
        _x, _y, _z = angle
        # print("-----------accelerate--------------------------------")
        # print("acc_x: {}, acc_y: {}, acc_z: {}".format(x, y, z))
        print("-----------angle-------------------------------------")
        print("x: {}, y: {}, z: {}\n _x: {}, _y: {}, _z: {}".format(x, y, z, _x, _y, _z))

        time.sleep(1)
